import { InjectQueue } from '@nestjs/bullmq';
import { Body, Controller, Post } from '@nestjs/common';
import { Queue } from 'bullmq';

@Controller('wepay')
export class WepayController {
  constructor(
    @InjectQueue('notify')
    private notifyQueue: Queue,
  ) {}

  @Post('/pay')
  async pay(@Body() data: any) {
    console.log(data);
    await this.notifyQueue.add('wepay', data);
    return {
      status: 'OK',
      message: 'SUCCESS',
    };
  }

  @Post('/refund')
  async refund(@Body() data: any) {
    console.log(data);
    await this.notifyQueue.add('wepay', data);
    return {
      status: 'OK',
      message: 'SUCCESS',
    };
  }
}
